<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view(TPL_FOLDER."header");?>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" >
  <tr>
    <td width="3%" align="left" ><img src="{tpl_path}images/forward.jpg" /></td>
    <td width="97%" align="left" >您现在的位置：生成网站地图</td>
  </tr>
</table>
<fieldset>
<legend>地图生成项</legend>
<form name="dialog_edit_form" id="dialog_edit_form">
  <table width="100%"  border="0" cellpadding="5" cellspacing="0"   style="line-height:30px; margin:10px">
    <tr>
      <td><input type="checkbox" name="mitem" id="mitem" value="sitemap_baidu" rel="百度地图" /> 百度地图&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="mitem" id="mitem" value="google" rel="谷歌地图" /> 谷歌地图</td>
    </tr>
    <tr>
      <td height="50" align="center" valign="bottom" style="border-bottom:#CCCCCC 1px solid"><input type="button" name="sbmit" onclick="ajax_make_html()" value="点击生成地图" class="button-style2" style="width:100px" />
       &nbsp;&nbsp;&nbsp;<input type="checkbox" onclick="check_box(this.form.mitem)" /> 全选</td>
    </tr>
    <tr>
      <td height="30" align="left" valign="middle">生成地图地址：<a href="<?php echo base_url().'sitemap_baidu.xml';?>" target="_blank">百度地图</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo base_url().'google.xml';?>" target="_blank">谷歌地图</a></td>
    </tr>
  </table>
</form>
</fieldset>
<div id="process_div" style="display:none"><table width="270" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td id="loading_img">&nbsp;</td>
  </tr>
  <tr>
    <td align="left" id="process_tips" style="line-height:25px">&nbsp;</td>
  </tr>
</table>
</div>
<script language="javascript">
var pId;
var mitem;
var process_html;
var loading_img="<img src=\"{tpl_path}images/ajax_loading.gif\" />";
function ajax_make_html(){
	mitem=$("input[name='mitem']:checked");
	$("#loading_img").html(loading_img);
	if(mitem.length==0)
	{
		alert("请选择要生成页面的项");
		return ;
	}
	$('#process_div').dialog({  
		hide:'',    
		autoOpen:false,
		width:300,
		height:310,  
		modal:true, //蒙层  
		title:'页面生成监视器', 
		close: function(){ 
			$(this).dialog('destroy');
		},  
		overlay: {  
			opacity: 0.5, 
			background: "black"
		},
		buttons:{ }
	});
	$("#process_tips").html("");
	$('#process_div').dialog('open');
	if($('#process_div').dialog('isOpen'))
	{
		process_html="";
		pId=0;
		ajax_process();
	}	
}

function ajax_process()
{
	if(pId>mitem.length-1) 
	{
		$("#loading_img").html("<b style=\"color:#006600\">全部生成完毕，请关闭该窗口</b>");
		return ;
	}
	var item_name=mitem.eq(pId).attr("rel");
	process_html+=(pId+1)+"、正在生成 "+item_name+"..........";
	$("#process_tips").html(process_html);
	$.ajax({
		url:js_root_path+"feed/ajax_make",
		data:"md5key=<?php echo md5($this->config->item('md5_encode_key'));?>&mitem="+mitem.eq(pId).val(),
		type:"POST",
		async:true,
		success:function(msg)
		{
			pId++;
			if(msg=="1")
			{
				process_html+="<b style=\"color:#006600\">生成完毕.</b><br>";
				$("#process_tips").html(process_html);
			}
			else
			{
				process_html+="<b style=\"color:#FF0000\">生成失败.</b><br>";
				$("#process_tips").html(process_html);
			}
			ajax_process();
		}
	});
}
</script>
<?php $this->load->view(TPL_FOLDER."footer");?>